package com.usian.article.controller;

import com.usian.article.ApAuthorControllerApi;
import com.usian.article.service.ApAuthorService;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/author")
public class ApAuthorController implements ApAuthorControllerApi {
    @Autowired
    private ApAuthorService apAuthorService;
    /**
     * 保存作者信息
     *
     * @param apAuthor
     * @return
     */
    @PostMapping("/save")
    @Override
    public ResponseResult saveApAuthor(@RequestBody ApAuthor apAuthor) {
        return apAuthorService.saveApAuthor(apAuthor);
    }

    /**
     * 根据用户id 查询作者信息
     *
     * @param userId
     * @return
     */
    @Override
    @GetMapping("findByUserId/{id}")
    public ApAuthor findByUserId(@PathVariable("id") Integer userId) {
        return apAuthorService.findByUserId(userId);
    }

}
